package com.yiyuan.app.controller;

import com.guaike.core.entity.result.Result;
import com.yiyuan.app.entity.annotation.Task;
import com.yiyuan.app.entity.enums.TaskTypeEnum;
import com.yiyuan.app.entity.param.BaseIdDTO;
import com.yiyuan.app.entity.param.BattleDTO;
import com.yiyuan.app.entity.result.*;
import com.yiyuan.app.service.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/task")
@Api(tags = "任务相关接口组")
@AllArgsConstructor
public class TaskController {

    private final TaskService taskService;

    @Task(taskType = TaskTypeEnum.daily_task)
    @GetMapping("/dailyList")
    @ApiOperation(value = "每日任务列表")
    public Result<List<TaskDailyVO>> dailyList() {
        return taskService.dailyList();
    }

    @Task(taskType = TaskTypeEnum.long_task)
    @GetMapping("/taskActionList")
    @ApiOperation(value = "松树日记类型列表")
    public Result<List<TaskActionVO>> taskActionList() {
        return taskService.taskActionList();
    }

    @Task(taskType = TaskTypeEnum.long_task)
    @GetMapping("/taskList")
    @ApiOperation(value = "松树日记列表")
    public Result<List<TaskVO>> taskList(@ApiParam(value = "松鼠日记类型", required = true) @RequestParam("action") Integer action) {
        return taskService.taskList(action);
    }

    @GetMapping("/vipProgress")
    @ApiOperation(value = "我的vip进度")
    public Result<VipLevelVO> vipProgress() {
        return taskService.vipProgress();
    }

    @GetMapping("/challengeRankList")
    @ApiOperation(value = "挑战榜列表")
    public Result<List<ChallengeRankVO>> challengeRankList(@ApiParam(value = "榜单类型(0:推币机，1：街机，2：娱乐)", required = true) @RequestParam("roomType") Integer roomType) {
        return taskService.challengeRankList(roomType);
    }

    @PostMapping("/getDailyTask")
    @ApiOperation(value = "领取每日任务")
    public Result<Boolean> getDailyTask(@RequestBody @Valid BaseIdDTO param) {
        return taskService.getDailyTask(param);
    }

    @PostMapping("/getTask")
    @ApiOperation(value = "领取松树日记任务")
    public Result<Boolean> getTask(@RequestBody @Valid BaseIdDTO param) {
        return taskService.getTask(param);
    }

    @PostMapping("/initiateBattle")
    @ApiOperation(value = "发起挑战")
    public Result<Boolean> initiateBattle(@RequestBody @Valid BattleDTO param) {
        return taskService.initiateBattle(param);
    }

    @PostMapping("/getBattlePrize")
    @ApiOperation(value = "领取挑战奖励")
    public Result<Boolean> getBattlePrize(@RequestBody @Valid BattleDTO param) {
        return taskService.getBattlePrize(param);
    }
}
